package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zarh {
   private zcfx a;
   private zapt b;

   public zarh(zapt var1) {
      this.b = var1;
   }

   void a(ArrayList var1, com.aspose.cells.a.f.zj var2) throws Exception {
      this.a = zarj.a("styles.xml", var2);
      zaqj var3 = new zaqj("text/xml", "styles.xml");
      com.aspose.cells.b.a.a.ze.a(var1, (Object)var3);
      this.a.c();
      this.a.b("office:document-styles");
      this.a.a("xmlns", "office", (String)null, "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
      this.a.a("xmlns", "style", (String)null, "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
      this.a.a("xmlns", "text", (String)null, "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
      this.a.a("xmlns", "table", (String)null, "urn:oasis:names:tc:opendocument:xmlns:table:1.0");
      this.a.a("xmlns", "draw", (String)null, "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
      this.a.a("xmlns", "fo", (String)null, "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
      this.a.a("xmlns", "xlink", (String)null, "http://www.w3.org/1999/xlink");
      this.a.a("xmlns", "dc", (String)null, "http://purl.org/dc/elements/1.1/");
      this.a.a("xmlns", "meta", (String)null, "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
      this.a.a("xmlns", "number", (String)null, "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0");
      this.a.a("xmlns", "svg", (String)null, "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
      this.a.a("xmlns", "chart", (String)null, "urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
      this.a.a("xmlns", "dr3d", (String)null, "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
      this.a.a("xmlns", "math", (String)null, "http://www.w3.org/1998/Math/MathML");
      this.a.a("xmlns", "form", (String)null, "urn:oasis:names:tc:opendocument:xmlns:form:1.0");
      this.a.a("xmlns", "script", (String)null, "urn:oasis:names:tc:opendocument:xmlns:script:1.0");
      this.a.a("xmlns", "ooo", (String)null, "http://openoffice.org/2004/office");
      this.a.a("xmlns", "ooow", (String)null, "http://openoffice.org/2004/writer");
      this.a.a("xmlns", "oooc", (String)null, "http://openoffice.org/2004/calc");
      if (this.b.n) {
         this.a.a("xmlns", "of", (String)null, "urn:oasis:names:tc:opendocument:xmlns:of:1.2");
      }

      this.a.a("xmlns", "dom", (String)null, "http://www.w3.org/2001/xml-events");
      this.a.a("office", "version", (String)null, this.b.m);
      this.a();
      this.b();
      zaph var4 = new zaph(this.b);
      var4.a(this.a);
      zaql var5 = new zaql(this.b);
      var5.a(this.a);
      this.a.b();
      this.a.d();
      this.a.e();
   }

   private void a() throws Exception {
      this.a.b("office:font-face-decls");
      Iterator var1 = this.b.b.iterator();

      while(var1.hasNext()) {
         zapw var2 = (zapw)var1.next();
         this.a(var2);
      }

      this.a.b();
   }

   private void b() throws Exception {
      this.a.b("office:styles");
      Iterator var1 = this.b.e.iterator();

      while(var1.hasNext()) {
         zaqb var2 = (zaqb)var1.next();
         this.a(var2);
      }

      zarf var6 = new zarf(this.b, this.a);
      Iterator var7 = this.b.f.iterator();

      while(var7.hasNext()) {
         zapq var3 = (zapq)var7.next();
         if (var3.c.getName() != null) {
            var6.a(var3);
         }
      }

      if (this.b.a.getWorksheets() != null && this.b.a.getWorksheets().getCount() > 0) {
         var7 = this.b.a.getWorksheets().iterator();

         label40:
         while(true) {
            Worksheet var8;
            do {
               do {
                  if (!var7.hasNext()) {
                     break label40;
                  }

                  var8 = (Worksheet)var7.next();
               } while(var8.getShapes() == null);
            } while(var8.getShapes().getCount() <= 0);

            Iterator var4 = var8.getShapes().iterator();

            while(var4.hasNext()) {
               Shape var5 = (Shape)var4.next();
               this.a(var5);
            }
         }
      }

      this.a.b();
   }

   private void a(Shape var1) throws Exception {
      if (var1 != null) {
         this.a.b("draw:fill-image");
         int var2 = var1.M().getIndex() + var1.x() + 1;
         this.a.a("draw", "name", (String)null, "D" + var2);
         MsoFillFormat var3 = var1.getFillFormat();
         switch(var3.c()) {
         case 2:
            this.a.a("xlink", "href", (String)null, var3.b());
         default:
            this.a.a("xlink", "show", (String)null, "embed");
            this.a.a("xlink", "actuate", (String)null, "onLoad");
            this.a.b();
         }
      }
   }

   private void a(zapw var1) throws Exception {
      this.a.b("style:font-face ");
      this.a.a("style", "name", (String)null, var1.a());
      this.a.a("svg", "font-family", (String)null, var1.a());
      if (!zaqh.e(var1.b())) {
         this.a.a("style", "font-family-generic", (String)null, var1.b());
      }

      if (!zaqh.e(var1.c())) {
         this.a.a("style", "font-pitch", (String)null, var1.c());
      }

      this.a.b();
   }

   private void a(zaqq var1, String var2) throws Exception {
      for(int var3 = 0; var3 < var1.b.size(); ++var3) {
         String[] var4 = (String[])((String[])var1.b.get(var3));
         this.a.a(var2, var4[0], (String)null, var4[1]);
      }

   }

   private void a(zaqb var1) throws Exception {
      String var2 = null;
      switch(var1.d) {
      case 0:
         var2 = "number:currency-style";
         break;
      case 1:
         var2 = "number:number-style";
         break;
      case 2:
         var2 = "number:date-style";
         break;
      case 3:
         var2 = "number:time-style";
         break;
      case 4:
         var2 = "boolean-style";
         break;
      case 5:
         var2 = "number:text-style";
         break;
      case 6:
         var2 = "number:percentage-style";
         break;
      case 7:
         var2 = "number:text-style";
      }

      this.a.b(var2);
      this.a.a("style", "name", (String)null, var1.a);

      int var3;
      for(var3 = 0; var3 < var1.e.size(); ++var3) {
         String[] var4 = (String[])((String[])var1.e.get(var3));
         String[] var5 = com.aspose.cells.b.a.zv.d(var4[0], ':');
         this.a.a(var5[0], var5[1], (String)null, var4[1]);
      }

      for(var3 = 0; var3 < var1.f.size(); ++var3) {
         zaqq var6 = (zaqq)var1.f.get(var3);
         switch(var6.a) {
         case 0:
            this.a.b("number:text");
            if (!zaqh.e(var6.c)) {
               this.a.a(var6.c);
            }

            this.a.b();
            break;
         case 1:
            this.a.b("number:text-content");
            this.a.b();
            break;
         case 2:
            this.a.b("style:text-properties");
            this.a(var6, "fo");
            this.a.b();
            break;
         case 3:
            this.a.b("number:currency-symbol");
            if (!zaqh.e(var6.c)) {
               this.a.a(var6.c);
            }

            this.a.b();
            break;
         case 4:
            this.a.b("number:number");
            this.a(var6, "number");
            this.a.b();
            break;
         case 5:
            this.a.b("style:map");
            this.a(var6, "style");
            this.a.b();
            break;
         case 6:
            this.a.b("number:year");
            this.a(var6, "number");
            this.a.b();
            break;
         case 7:
            this.a.b("number:month");
            this.a(var6, "number");
            this.a.b();
            break;
         case 8:
            this.a.b("number:day");
            this.a(var6, "number");
            this.a.b();
            break;
         case 9:
            this.a.b("number:hours");
            this.a(var6, "number");
            this.a.b();
            break;
         case 10:
            this.a.b("number:minutes");
            this.a(var6, "number");
            this.a.b();
            break;
         case 11:
            this.a.b("number:seconds");
            this.a(var6, "number");
            this.a.b();
            break;
         case 12:
            this.a.b("number:am-pm");
            this.a.b();
            break;
         case 13:
            this.a.b("number:fraction");
            this.a(var6, "number");
            this.a.b();
            break;
         case 14:
            this.a.b("number:scientific-number");
            this.a(var6, "number");
            this.a.b();
            break;
         case 15:
            this.a.b("number:day-of-week");
            this.a(var6, "number");
            this.a.b();
         }
      }

      this.a.b();
   }
}
